package com.trkj;

import com.trkj.config.AppConfig;
import com.trkj.jdk.LogService;
import com.trkj.service.EmpService;
import com.trkj.service.impt.Service;
import com.trkj.service.impt.phoneService;
import com.trkj.service.order;
import com.trkj.service.phone;
import lombok.extern.slf4j.Slf4j;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

@Slf4j
public class zy {
    private static ApplicationContext context1;
    private static ApplicationContext context2;
    @BeforeClass
    public static void init(){
        context1=new ClassPathXmlApplicationContext("zy2.xml");
        context2=new AnnotationConfigApplicationContext(AppConfig.class);
    }
    @Test
    public void test1(){
        order or=context1.getBean(order.class);
        or.xia();
        or.update();
        or.fahuo();
    }
    @Test
    public void test3(){
       phoneService p=context1.getBean(phoneService.class);
       p.call();
       p.sendMessage();
    }
    @Test
    public void test2(){
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("zy.xml");
        order or = context.getBean(order.class);
        or.xia();
        or.update();
        or.fahuo();

        context.close();
    }
    @Test
    public void test5(){

        LogService logService = context2.getBean(LogService.class);

        logService.addProductToInventory();
        logService.addNewProduct();
    }
    @Test
    public  void test6(){
        Service service = (Service) context1.getBean("service");
        service.fun();
    }
    @Test
    public void zy1(){
        Service service =context2.getBean(Service.class);
        service.fun();
    }
}
